import {h} from 'vue'
import * as icons from '@ant-design/icons-vue'

interface Module {
    [p: string]: any
}

const AIcon = (props: { icon: string }) => {
    const im: Module = icons
    return h(im[toCamcelCase(props.icon)])
}

function toCamcelCase(str: string) {
    // return str.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
    //up-square-outlined
    return str.split('-').map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join("")
}

export default AIcon
